home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 236 / 236.d81 / t.inside dotb < prev    next >
Text File  |  2022-08-26  |  9KB  |  298 lines

  1. u
  2.            INSIDE DOTBASIC
  3.            by Dave Moorman
  4.  
  5.  
  6.     While I expect DotBASIC to become
  7. my own programming environment of
  8. choice, I created it for one central
  9. purpose:
  10.  
  11.     To understand modern programming
  12. concepts by emulating and implimenting
  13. them.
  14.  
  15.     The project grew out of
  16. discussions with my PC guru, Kevin
  17. Barrows, about the ways and means of
  18. 6510 ML, BASIC 2.0, and Mr.Mouse.
  19. Probably the single most seminal
  20. comment came from Kevin when he
  21. identified the "operating system" of
  22. the raw C-64 as not so much an OS, but
  23. a full implimentation of BASIC on all
  24. upper levels.
  25.  
  26.     He is right. We do not have a
  27. Command Line Interface (CLI). We have
  28. a BASIC command that LOADs whatever it
  29. is we want in memory. That is BASIC,
  30. right off the bat.
  31.  
  32.     Rightfully so! This is, after all,
  33. a 64K computer (with a 16K bag of ROM
  34. and a 4K bowl of I/O). Memory is in
  35. short supply and an independent
  36. operating system is pricey. The C-64,
  37. being eternally tied to the crippled
  38. 1541 and designd with a cassette tape
  39. device in mind as the primary
  40. peripheral, does not have any
  41. boot-sector capabilities. One can turn
  42. on a C-64 with no storage device
  43. whatsoever and have everything
  44. necessary to write and execute
  45. software.
  46.  
  47.     (The 64K limitation is not, in and
  48. of itself, reason enough to forego an
  49. independent OS. CP/M was designed for
  50. 64K Z-80 computers and could handle
  51. large programs and data by swapping
  52. code and data to and from the disk.
  53. Similarly, GEOS offers a working
  54. Graphics User Interface operating
  55. system by the same use of disk
  56. "memory." The C-64's problem was the
  57. rather slow disk access speed, which
  58. early GEOS users discovered was
  59. painfully slow. Many of you have
  60. overcome such problems and make the
  61. C-64/128 do everything you need done.)
  62.  
  63.     In my view, BASIC 2.0 has three
  64. things going for it as a "proto-OS"/
  65. language:
  66.  
  67. 1. It is not bad, considering the
  68.    limitations of the machine. Eight K
  69.    of ROMis not large, so features had
  70.    to be whittled down to the
  71.    essentials.
  72.  
  73. 2. It is free -- not only financially,
  74.    but also memory-wise. Putting GEOS
  75.    or any other OS on a C-64 consumes
  76.    precious RAM, and may or may not
  77.    utilize a fairly incredible library
  78.    of useful routines in ROM.
  79.  
  80. 3. It is adaptable. The 6510 processor
  81.    allows full 64K of RAM. Moreover,
  82.    according to Jim Butterfield, the
  83.    designers of the C-64 were urged by
  84.    software developers to include as
  85.    many RAM vectors as possible so the
  86.    ROM was not absolutely "hard
  87.    coded." Anyone crazy enough can
  88.    "improve" on the Machine that Jack
  89.    Built!
  90.  
  91. (I have read how one can build a true
  92. multi-tasking BASIC that will run two
  93. programs at once. Pages 0 and 1 must
  94. be swapped in and out of memory, and a
  95. 1Mhz processor moves a tad slow for
  96. such to be very practical. But it
  97. [can] be done!)
  98.  
  99.     In fact, such "possibility" is the
  100. great fascination for me. We can do --
  101. or at least "model" -- any
  102. computational project on the C-64. The
  103. results may not be completely
  104. practical, but the intellectual
  105. challenges are stimulating, to say the
  106. least. And the knowledge attained is
  107. enlightening. (While I find Windows 98
  108. unconscionably flawed, I have great
  109. respect for the programmers who made
  110. it (almost) work.)
  111.  
  112.     So, could I approach a Visual
  113. Design, Object Oriented, Event Driven
  114. programming environment? Of course! I
  115. already had many of the tools: BASIC
  116. ROM, RAM Vectors, Mr.MOUSE, and my own
  117. MR.MICK.
  118.  
  119.     The Event Driven concept (learned
  120. while using Visual Basic on my Windows
  121. PC) reminded me of something I had
  122. ready many years ago (circa 1993) in
  123.  
  124.      [Advanced Machine Language]
  125.       [Programming on the C-64]
  126.  
  127. by Lothat Englisch, published by
  128. Abacus Software in 1984.
  129.  
  130.     Englisch showed how to use the NMI
  131. timer to trigger a "behind the scenes"
  132. GOSUB. The trick is to wedge code into
  133. the STOP Vector -- which is called
  134. during a program between BASIC
  135. commands. The location of th
  136. subroutine line number is found during
  137. initialization and stored away -- and
  138. the Event Sensing routine is wedged
  139. into the STOP Vector. When the Event
  140. happens, the current line number and
  141. text pointer data are pushed onto the
  142. processor stack, along with the GOSUB
  143. token. The stored address is put into
  144. the text pointer, and BASIC is
  145. suddenly looking at the Subroutine!
  146.  
  147.     Though BASIC 2.0 requires a Main
  148. Loop to keep it in Program Mode, Event
  149. Driven programming is fairly easy to
  150. impliment.
  151.  
  152.     For that Main Loop, I wanted to
  153. use another idea Englisch included in
  154. the book -- a REPEAT-UNTIL loop. This
  155. also monkeys with the stack in much
  156. the same way as the pseudo-GOSUB,
  157. except the DO (I decided I like DO
  158. better than REPEAT) stuffs its line
  159. number and text pointer data onto the
  160. stack. UNTIL does not pull the data.
  161. It just uses it to take the program
  162. back to the DO, until the condition is
  163. True. Then the stack is flushed, and
  164. life (and the program) goes on.
  165.  
  166.     The DO-UNTIL/WHILE code does not
  167. do well from a SYS command. The
  168. two-bytes in the stack for the RTS get
  169. in the way. So, for this reason alone,
  170. I needed some form of "real" command.
  171.  
  172.     There are three ways to use ML
  173. routines in a BASIC program. The SYS
  174. is nice, since it does not necessarily
  175. upset Vector setting, something we
  176. like at LOADSTAR!
  177.  
  178.     The second method involved three
  179. Vectors. One wedges into the
  180. Tokenizer, searches for new command
  181. names, and puts new tokens in BASIC
  182. memory. The second wedges in the List
  183. Vector to display the new commands.
  184. The third is a wedge in the Command
  185. Vector that recognizes the new tokens
  186. and sends the interpreter to their
  187. respective code.
  188.  
  189.     What a bunch of work!
  190.  
  191.     The third method is to use a
  192. Command Vector wedge to watch for a
  193. particular character in the BASIC
  194. code. If found, the following
  195. character(s) represent a new command.
  196. I chose a [period] for the identifying
  197. character because it is unique, and
  198. easy to read around.
  199.  
  200.     Hence -- DotBASIC!
  201.  
  202.     Then I decide on two-character
  203. command names. These are harder to
  204. read and remember than full command
  205. names. But they have a real advantage.
  206.  
  207.     The addresses of the respective
  208. routines are two bytes long. If I
  209. search a table of two-character names
  210. and find the one listed, the index can
  211. point to a matching table of two byte
  212. addresses.
  213.  
  214.     Before I got too far, I needed to
  215. incorporate the Visual Design idea.
  216. Here is where Mr.MOUSE comes in. Lee
  217. Novak included defined screen Regions
  218. that the mouse recognizes. The data
  219. for these regions is in a 1 page block
  220. of memory. Now, if that block was
  221. included with a pre-designed screen,
  222. and other data like line numbers,
  223. hotkeys, and colors was in another
  224. block of data, and these could be
  225. saved and loaded into a program -- BY
  226. GOLLY, we've got Visual Design!
  227.  
  228.     And I had Mr.MICK, the Mr.MOUSE
  229. Image Construction Kit, all ready
  230. working. One file type, FTS, includes
  231. the Font, Screen, and Color
  232. information. So I stretched it by two
  233. pages and added Region and Event data.
  234. At the time, I was thinking of calling
  235. this language:
  236.  
  237.     Mouse Event Driven Development
  238.          Language Experiment
  239.  
  240.                 MEDDLE
  241.  
  242.     So the extension for the file was
  243. .MED. Maybe I will change it with the
  244. next version.
  245.  
  246.     And lastly, the question of Object
  247. Oriented Programming was discussed
  248. long and hard and far into the night
  249. at the local truck stop coffee shop.
  250. In Visual Basic and other OOP
  251. languages, everything is an object
  252. with properties.
  253.  
  254.     For instance, a sprite is a screen
  255. object, but it also is a programming
  256. object, with properties such as
  257. position, color, width, priority,
  258. image, etc. Now, in a full OOP, you
  259. would name each sprite, then have
  260. access to all the properties as
  261. variables. Say the sprites name is
  262. MAN. Then you could change the color
  263. of MAN with:
  264.  
  265.         MAN.COLOR = white
  266.  
  267.     Every property has a name,
  268. attached to the objects name with a
  269. dot. I tried to make something like
  270. this work, but the overhead became
  271. just too pricey. You can approach OOP
  272. in your own programming by using
  273. arrays loaded with the register
  274. information:
  275.  
  276.         SC(n) = Sprite Color
  277.         FOR X=0to7:SC(X)=53287+x:NEXT
  278.  
  279. To change the color of Sprite 1:
  280.  
  281.         POKE SC(1),0
  282.  
  283. Which is easier -- and certainly OOP!
  284.  
  285.     In DotBASIC, we have Screen
  286. Objects that are an